<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('部门调动登记')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                姓名：<input type="text" name="name"/>
                            </li>
                            <li>
                                工号：<input type="text" name="badge"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addFull()">
                    <i class="fa fa-plus"></i> 添加员工
                </a>
                <a class="btn btn-primary single" onclick="$.operate.edit()">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                    <i class="fa fa-remove"></i> 删除
                </a>
                &nbsp;&nbsp;&nbsp;
                <a class="btn btn-primary" onclick="threeProcedure('eSP_ChangeOrgCheck')">
                    <i class="fa fa-edit"></i> 确认检查
                </a>
                <a class="btn btn-danger" onclick="threeProcedure('eSP_ChangeOrgCancel')">
                    <i class="fa fa-remove"></i> 取消确认
                </a>
                <a class="btn btn-primary" onclick="threeProcedure('eSP_ChangeOrgStart')">
                    执行部门调动
                </a>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>

<script th:inline="javascript">
    var prefix = ctx + "changeManage/DepChange";
    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        queryData();
    });

    function queryData() {
        var columns = [];
        var checkbox = {checkbox: true};
        var id = {field: 'id', title: '序号'};
        var badge = {field: 'badge', title: '工号'};
        var name = {field: 'name', title: '姓名'};
        var compName = {field: 'compName', title: '公司名称'};
        var depName = {field: 'depName', title: '部门名称'};
        var jobName = {field: 'jobName', title: '工作岗位'};
        var empStatusName = {field: 'empStatusName', title: '员工状态'};
        var joindate = {field: 'joindate', title: '入职日期'};
        var WorkCityTitle = {field: 'WorkCityTitle', title: '工作城市'};
        var empTypeName = {field: 'empTypeName', title: '员工类型'};
        var ReportToName = {field: 'ReportToName', title: '行政上级'};
        var WfReportToName = {field: 'WfReportToName', title: '职能上级'};
        var NewCompName = {field: 'NewCompName', title: '*新公司名称'};
        var NewDepName = {field: 'NewDepName', title: '*新部门名称'};
        var NewJobName = {field: 'NewJobName', title: '*新工作岗位'};
        var NewWorkcity = {field: 'NewWorkcity', title: '*新工作城市'};
        var NewEmpType = {field: 'NewEmpType', title: '*新员工类型'};
        var NewReportToName = {field: 'NewReportToName', title: '新直接上级'};
        var NewWfReportToName = {field: 'NewWfReportToName', title: '新职能上级'};
        var orgchangetypeTitle = {field: 'orgchangetypeTitle', title: '*调动类型'};
        var orgchangeReasonTitle = {field: 'orgchangeReasonTitle', title: '*调动原因'};
        var salarycompTitle = {field: 'salarycompTitle', title: '*发薪公司'};
        var EffectDate = {field: 'EffectDate', title: '*生效日期'};
        var Remark = {field: 'Remark', title: '备注'};
        var RegByName = {field: 'RegByName', title: '登记人'};
        var RegDate = {field: 'RegDate', title: '登记时间'};
        var Initialized = {field: 'Initialized', title: '?确认'};
        var InitializedByName = {field: 'InitializedByName', title: '确认人'};
        var InitializedTime = {field: 'InitializedTime', title: '确认时间'};


        columns.push(checkbox,id,badge,name,compName,depName,jobName,empStatusName,joindate,WorkCityTitle);
        columns.push(empTypeName,ReportToName,WfReportToName,NewCompName,NewDepName,NewJobName,NewWorkcity);
        columns.push(NewEmpType,NewReportToName,NewWfReportToName,orgchangetypeTitle,orgchangeReasonTitle);
        columns.push(salarycompTitle,EffectDate,Remark,RegByName,RegDate,Initialized,InitializedByName,InitializedTime);



        var options = {
            code: "id",
            uniqueId: "id",
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            detailUrl: prefix + "/detail/{id}",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            height: $(window).height() - 120,
            sortOrder: "desc",
            modalName: "部门调动登记",
            columns: columns
        };
        $.table.init(options);
    }

    function threeProcedure(procedure){
        var allId = "";
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allId += row[i].id
            } else {
                allId += row[i].id + ","

            }
        }
        $.ajax({
            url: prefix + "/procedure",
            data: {"allId": allId, "procedure": procedure},
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.data == null) {
                    $.modal.alertWarning(data.message);
                } else {
                    $.modal.alertSuccess(data.data);
                }

                $.table.refresh();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }


</script>
</body>
</html>